package fr.appliClient.server.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import fr.appliClient.server.dao.MaintenanceDao;
import fr.appliClient.server.entity.Maintenance;
import fr.appliClient.server.entity.Vehicle;

@Service
public class MaintenanceService {

	@Autowired
	private MaintenanceDao dao;

	/**
	 * Get the date of the next maintenance for a vehicle.
	 * 
	 * @param vehicle
	 * @return
	 */
	public Date getNextMaitenanceDate(Vehicle vehicle) {

		Date ret = null;
		Maintenance m = this.dao.getNext(vehicle.getRegistration());
		if (m != null) {
			ret = m.getDate();
		}
		return ret;
	}

}
